package com.xbongbong.paas.pojo;

import com.xbongbong.pro.enums.businessrule.enums.RuleVersionEnum;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.validator.constraints.Length;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * @author: wufeng
 * @date: 2018/12/24 16:25
 * @desrcption: 生效时规则
 */
@Getter
@Setter
@ToString
public class ActiveRulePoJo implements Serializable {
    private static final long serialVersionUID = 7293401186947606654L;

    /**
     * 业务规则名称
     */
    @NotEmpty(message = "{pojo.msg.ActiveRule.name.NotEmpty}")
    private String name;

    /**
     * 规则类型 1表示简易模式，2表示高级模式
     * @see RuleVersionEnum
     */
    @NotNull(message = "{pojo.msg.ActiveRule.type.NotNull}")
    private Integer type;

    /**
     * 规则内容
     */
    @Valid
    private RulePoJo rule;

    /**
     * 备注信息
     */
    @Length(max= 500, message = "{pojo.msg.ActiveRule.memo.Length}")
    private String memo;

    /**
     * 是否启用 1： 启用； 否：不启用
     */
    @NotNull(message = "{pojo.msg.ActiveRule.enable.NotNull}")
    private Integer enable;

    private Integer packageLimit;

    private String message;

    public ActiveRulePoJo() {
        enable = 0;
    }

    public ActiveRulePoJo(@NotEmpty(message = "{pojo.msg.ActiveRule.name.NotEmpty}") String name, @NotNull(message = "{pojo.msg.ActiveRule.type.NotNull}") Integer type, @Valid RulePoJo rule, @Length(max = 500, message = "{pojo.msg.ActiveRule.memo.Length}") String memo, @NotNull(message = "{pojo.msg.ActiveRule.enable.NotNull}") Integer enable) {
        this.name = name;
        this.type = type;
        this.rule = rule;
        this.memo = memo;
        this.enable = enable;
    }
}
